<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <style></style>
  </head>
  <body>
    <div>promise静态方法</div>
    <script>
      //   Promise.resolve();快速把值转换为promise对象
      let r = Promise.resolve("foo");
      console.log(r); //Promise {<resolved>: "foo"}

      Promise.resolve("foo").then(
        (res) => {
          console.log(res);
        },
        (err) => {
          console.log(err);
        }
      );
      //这个等价于上面的静态方法
      new Promise((resolve, reject) => {
        resolve("foo");
      });

      //快速创建一个一定失败的promise对象·2
      Promise.reject(new Error("err")).catch((err) => {
        console.log(err);
      });
    </script>
  </body>
</html>
